package com.yh.csx.bsf.flow.dao.dal;


import com.yh.csx.bsf.flow.core.db.DbConn;
import com.yh.csx.bsf.core.util.ConvertUtils;
import com.yh.csx.bsf.flow.core.util.ArrayUtil;
import com.yh.csx.bsf.flow.dao.dal.auto.t_department_base_dal;
import com.yh.csx.bsf.flow.dao.dal.auto.t_department_user_base_dal;
import com.yh.csx.bsf.flow.dao.model.auto.t_department_model;
import com.yh.csx.bsf.flow.dao.model.auto.t_department_user_model;
import lombok.val;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

public class t_department_user_dal extends t_department_user_base_dal {

    public ArrayList<t_department_user_model> getListByFirstDepartment(DbConn conn,int first_department_id,int user_id) {
        val rs = new ArrayList<t_department_user_model>();
        val stringSql = new StringBuilder();
        stringSql.append("select s.* from t_department_user s where first_department_id=? and user_id=?");
        val ds = conn.executeList(stringSql.toString(), new Object[]{first_department_id,user_id});
        if (ds != null && ds.size() > 0) {
            for (Map<String, Object> dr : ds) {
                rs.add(createModel(dr));
            }
        }
        return rs;
    }

    public ArrayList<t_department_user_model> getListByDepartment(DbConn conn, List<Integer> departmentIds) {
        val rs = new ArrayList<t_department_user_model>();
        val stringSql = new StringBuilder();
        stringSql.append("select s.* from t_department_user s where department_id in ("+ ArrayUtil.sqlIn(departmentIds) +")");
        val ds = conn.executeList(stringSql.toString(), new Object[]{});
        if (ds != null && ds.size() > 0) {
            for (Map<String, Object> dr : ds) {
                rs.add(createModel(dr));
            }
        }
        return rs;
    }
}